Array.prototype.contains = function(element) {
	return this.indexOf(element) != -1;
};

$.validate = function(selector, rules, invalid) {
	return $(selector).validate({
		rules: rules,
		highlight: function(element) {
			$(element).closest('.form-group').addClass('has-error');
		},
		unhighlight: function(element) {
			$(element).closest('.form-group').removeClass('has-error');
		},
		errorElement: 'span',
		errorClass: 'help-block',
		errorPlacement: function(error, element) {
			if (element.parent('.input-group').length)
				error.insertAfter(element.parent());
			else
				error.insertAfter(element);
		},
		invalidHandler: invalid
	});
};